<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>


<title>商品管理 - 商品基本信息管理</title>


<%--<link rel="stylesheet" href="${contextPath}/static/layer/css/layui.css" media="all">--%>
<link rel="stylesheet" href="${contextPath}/static/ace/components/_mod/jquery-ui/jquery-ui.css"/>
<%--<link rel="stylesheet" href="${contextPath}/static/statistics/css/bootstrap-datetimepicker.min.css">--%>
<link rel="stylesheet"
	  href="${contextPath}/static/ace/components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css"/>
<link rel="stylesheet" href="${contextPath}/static/ace/components/_mod/jqgrid/ui.jqgrid.css"/>
<%--<jsp:include page="../../head.jsp"/>--%>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.min.js"></script>
<%--<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.fr.js"></script>--%>
<script src="${contextPath}/static/statistics/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${contextPath}/static/statistics/js/vue.js"></script>
<script src="${contextPath}/static/countjs/regularYz.js"></script>
<script src="${contextPath}/static/franchisee/form.js"></script>
<link href="${contextPath}/static/ztree/css/zTreeStyle.css" rel="stylesheet" />
<style type="text/css">
	.customBtn {
		line-height: 20px;
		margin-bottom: 3px;
	}

	.btnLine {
		margin-left: 1px;
		margin-top: 8px;
		margin-bottom: 2px;
	}

	@-webkit-keyframes bouncedelay {
		0%, 80%, 100% {
			-webkit-transform: scale(0.0)
		}
		40% {
			-webkit-transform: scale(1.0)
		}
	}

	@keyframes bouncedelay {
		0%, 80%, 100% {
			transform: scale(0.0);
			-webkit-transform: scale(0.0);
		}
		40% {
			transform: scale(1.0);
			-webkit-transform: scale(1.0);
		}
	}

	.autocomplete-suggestions {
		border: 1px solid #999;
		background: #FFF;
		overflow: auto;
	}

	.autocomplete-suggestion {
		padding: 2px 5px;
		white-space: nowrap;
		overflow: hidden;
	}

	.autocomplete-selected {
		background: #F0F0F0;
	}

	.autocomplete-suggestions strong {
		font-weight: normal;
		color: #3399FF;
	}

	@-moz-document url-prefix() {
		fieldset {
			display: table-cell;
		}
	}

	.ui-jqgrid-sortable {
		text-align: center;
	}

	.ui-jqgrid-sortable {
		text-align: center;
	}

</style>

<div class="row" id="app">
    <div class="row btnLine">
        <div class="button-len col-sm-12">
            <%--<shiro:hasPermission name="USER:ADD">--%>
                <button type="button" class="btn btn-white btn-sm btn-purple customBtn" id="addCargo">
                    <i class="ace-icon fa fa-plus-circle purple"></i> 新增
                </button>
            <%--</shiro:hasPermission>--%>

            <%--<shiro:hasPermission name="USER:EDIT">--%>
                <button type="button" class="btn btn-white btn-info btn-sm customBtn" id="editProd">
                    <i class="ace-icon fa fa-pencil blue"></i> 修改
                </button>
            <%--</shiro:hasPermission>--%>
			<label style="">状态</label>
			<select class="input-sm" id="state1">
				<option selected="selected" value="1">正常</option>
				<option value="2">停售</option>
				<option value="3">停购</option>
				<option value="4">淘汰</option>
			</select>
			<%--<input id="prodInput1" onfocus="this.data=''" class="input-sm" type="text"--%>
				   <%--placeholder="商品大类" style="width: 100px;">--%>

			<select class="input-sm" id="isExpInput">
				<option value="0">商品类型</option>
				<option :value="obj.typeId" v-for="(obj, index) in yanType1">
					{{ obj.typeName }}
				</option>

			</select>
			<select class="input-sm" id="isAuthInput">
				<option value="-1">商品大类</option>
				<option :value="obj.typeId" v-for="(obj, index) in yanType2">
					{{ obj.typeName }}
				</option>
			</select>

			<select class="input-sm" id="isAuthInput1">
				<option value="-1">商品中类</option>
				<option :value="obj.typeId" v-for="(obj, index) in yanType3">
					{{ obj.typeName }}
				</option>
			</select>

			<select class="input-sm" id="isAuthInput2">
				<option value="-1">商品小类</option>
				<option :value="obj.typeId" v-for="(obj, index) in yanType4">
					{{ obj.typeName }}
				</option>
			</select>

            <input class="input-sm" type="text" id="productCode1" style="margin-left: 2px;"
                   placeholder="商品条码">
            <input class="input-sm" type="text" id="productName1" style="margin-left: 2px;"
                   placeholder="商品名称">
			<input class="input-sm" type="text" id="supplierName" style="margin-left: 2px;"
				   placeholder="供应商名称">
            <button type="button" class="btn btn-sm btn-white btn-info search-len customBtn"
                    onclick="searchProd()">
                <i class="ace-icon fa fa-search orange"></i>搜索
            </button>
		</div>
		<div class="button-len col-sm-12 hide" id="commodityScreen" style="border-top: solid 1px #F5F5F5; margin-top: 5px;">
			<div style="width: 100%;margin-top: 5px; margin-bottom: 5px;">
				<label for="" style="">商品筛选</label><br/>
				<label for="" style="margin-left: 25px">品牌：</label>
				<label class="checkbox-inline">
					<input type="checkbox" id="inlineCheckbox1" value="option1"> 选项 1
				</label>
				<label class="checkbox-inline">
					<input type="checkbox" id="inlineCheckbox2" value="option2"> 选项 2
				</label>
				<label class="checkbox-inline">
					<input type="checkbox" id="inlineCheckbox3" value="option3"> 选项 3
				</label>
			</div>
			<div style="width: 100%">
				<label for="" style="">工业信息：</label>
				<select class="input-sm">
					<option>中国烟草总公司</option>
					<option>上海烟草集团公司</option>
					<option>贵州中烟工业有限责任公司</option>
				</select>
			</div>
        </div>
	</div>

   <div class="row" style="background-color: #3321; width: 97.4%;margin-left: 15px;">

		<div class="col-xs-12">
			<table id="grid-product-table"></table>
			<div id="grid-product-pager"></div>
		</div>
   </div>

	<!--  模态框（Modal） -->
	<!-- 品牌 -->
	<div id="container">
		<div id="example1" class="modal fade">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<a class="close" data-dismiss="modal">×</a>
						<h3>品牌列表</h3>
					</div>
					<div class="modal-body">
						<div class="row btnLine" style="margin-bottom: 10px;">
							<div class="button-len col-sm-12">
								<label style="margin-left: -13px;">品牌名称</label>
								<input class="input-sm" type="text" id="searcBrandName" style="margin-left: 5px;"
									   placeholder="品牌名称">
								<button type="button" class="btn btn-sm btn-white btn-info search-len customBtn"
										onclick="searchProduct()">
									<i class="ace-icon fa fa-search orange"></i>搜索
								</button>
							</div>
						</div>

						<table id="grid-brand-table"></table>
						<div id="grid-brand-pager"></div>
					</div>
				</div>
			</div>
		</div>
		<!-- 类别  -->
		<div id="example2" class="modal fade">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<a class="close" data-dismiss="modal">×</a>
						<h3>品牌列表</h3>
					</div>
					<div class="modal-body">
						<div class="row btnLine" style="margin-bottom: 10px;">
							<div class="button-len col-sm-12">

							</div>
						</div>

						<table id="grid-prodType-table"></table>
						<div id="grid-prodType-pager"></div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 新增修改数型内容 -->
	<div id="authorizationInfoContentProd" class="hide">
		<div class="content_wrap" id="treeDemoProd">
			<div class="zTreeDemoBackgroundProd left" style="width: 600px; margin-left: 23px;">
				<form id="productForm">
					<table class="table">
						<tbody>
						<tr>
							<input type="text" class="form-control hide" id="productId" name="productId" placeholder="id" style="width: 150px; height: 20px;">
							<td style="width: 86px; text-align: right">
								条码
							</td>
							<td>
								<input type="text" class="form-control" readonly="readonly"  onkeyup="value=value.replace(/[^\d]/g,'')" id="productCode" name="productCode" placeholder="编码" style="width: 150px; height: 20px;">
							</td>
							<td style="width: 86px; text-align: right">
								自编码
							</td>
							<td>
								<input type="text" class="form-control" id="selfCode" name="selfCode" placeholder="自编码" style="width: 150px; height: 20px;">
							</td>
						</tr>

						<tr>
							<td style="width: 86px; text-align: right">
								商品名称
							</td>
							<td>
								<input type="text" class="form-control" id="productName" name="productName" placeholder="品名" style="width: 150px; height: 20px;">
							</td>
							<td style="width: 86px; text-align: right">
								品牌
							</td>
							<td>
								<input type="text" class="form-control" placeholder="品牌" id="brandName" name="brandName" style="width: 150px; height: 20px;" readonly>
								<input type="text" class="form-control" placeholder="品牌编码" id="prodBrandId" name="prodBrandId" style="display: none">
							</td>
						</tr>

						<tr>
							<td style="width: 86px; text-align: right">
								简称
							</td>
							<td>
								<input type="text" class="form-control" id="shortName" name="shortName" placeholder="简称" style="width: 150px; height: 20px;">
							</td>
							<td style="width: 86px; text-align: right">
								商品分类
							</td>
							<td>
								<input type="text" class="form-control" id="productTypeId" name="productTypeId" placeholder="类别" style="width: 150px; height: 20px; display: none;">
								<input type="text" class="form-control" id="prodTypeId" name="prodTypeId" placeholder="类别" style="width: 150px; height: 20px; display: none;">
								<input type="text" class="form-control" id="typeName" name="typeName" placeholder="类别" style="width: 150px; height: 20px;" readonly>
							</td>
						</tr>

						<tr>
							<td style="width: 86px; text-align: right">
								规格
							</td>
							<td>
								<input type="text" class="form-control" id="spec" name="spec" placeholder="规格" style="width: 150px; height: 20px;">
							</td>
							<td style="width: 86px; text-align: right">
								属性
							</td>
							<td>
								<input type="text" class="form-control" id="" name="" placeholder="属性" style="width: 150px; height: 20px;">
							</td>
						</tr>

						<%--<tr>--%>
						<%--<td style="width: 86px; text-align: right">--%>
						<%--经营方式--%>
						<%--</td>--%>
						<%--<td>--%>
						<%--<select class="form-control" id="operatorWay" style="width: 150px; height: 20px;">--%>
						<%--<option selected="selected" value="A">购销</option>--%>
						<%--<option value="C">联营</option>--%>
						<%--<option value="F">扣率代销</option>--%>
						<%--</select>--%>
						<%--</td>--%>
						<%--<td style="width: 86px; text-align: right">--%>
						<%--联营扣率--%>
						<%--</td>--%>
						<%--<td>--%>
						<%--<input type="text" class="form-control" id="" placeholder="联营扣率" style="width: 150px; height: 20px;">--%>
						<%--</td>--%>
						<%--</tr>--%>

						<tr>
							<td style="width: 86px; text-align: right">
								进货规格
							</td>
							<td>
								<input type="text" class="form-control" id="stockSpec" name="stockSpec" placeholder="进货规格" style="width: 150px; height: 20px;">
							</td>
							<td style="width: 86px; text-align: right">
								毛利率
							</td>
							<td>
								<input type="text" class="form-control" id="" placeholder="毛利率" style="width: 150px; height: 20px;">
							</td>
						</tr>
						<tr>
							<td style="width: 86px; text-align: right">
								商品类型
							</td>
							<td>
								<select class="form-control" id="productType" name="productType" style="width: 150px; height: 20px;">
									<option selected="selected" value="1">普通商品</option>
									<option value="2">捆绑商品</option>
									<option value="3">专柜类型</option>
									<option value="4">服务类型</option>
									<option value="5">消耗品类型</option>
									<option value="6">紧俏商品</option>

								</select>
							</td>
							<td style="width: 86px; text-align: right">
								计价方式
							</td>
							<td>
								<select class="form-control" id="freezeAccounts" name="freezeAccounts" style="width: 150px; height: 20px;">
									<option selected="selected" value="0">正常</option>
									<option value="1">冻结</option>
								</select>
							</td>
						</tr>


						<tr>
							<td style="width: 86px; text-align: right">
								进价
							</td>
							<td>
								<input type="text" class="form-control" id="cstPrice" name="cstPrice" placeholder="进价" style="width: 150px; height: 20px;">
							</td>
							<td style="width: 86px; text-align: right">
								零售价
							</td>
							<td>
								<input type="text" class="form-control" id="rtlPrice" name="rtlPrice" placeholder="零售价" style="width: 150px; height: 20px;">
							</td>
						</tr>

						<tr>
							<td style="width: 86px; text-align: right">
								团购价
							</td>
							<td>
								<input type="text" class="form-control" id="dispatchPrice" name="dispatchPrice" value="" placeholder="团购价" style="width: 150px; height: 20px;">
								<span id="deliverCycleMsg" style="color: red"></span>
							</td>
							<td style="width: 86px; text-align: right">
								最低售价
							</td>
							<td>
								<input type="text" class="form-control" id="bankOfDeposit" name="bankOfDeposit" placeholder="最低售价" style="width: 150px; height: 20px;">
								<span id="bankOfDepositMsg" style="color: red"></span>
							</td>
						</tr>
						
						<tr>
							<td style="width: 86px; text-align: right">
								批条价 
							</td>
							<td>
								<input type="text" class="form-control" id="dispatchPcsPrice" name="dispatchPcsPrice" value="" placeholder="批条价" style="width: 150px; height: 20px;">
								<span id="dispatchPcsPriceMsg" style="color: red"></span>
							</td>
							<td style="width: 86px; text-align: right">
								备注
								<!-- 最低售价 -->
							</td>
							<td>
								<input type="text" class="form-control" id="remark" name="remark" placeholder="备注" style="width: 150px; height: 20px;">
								<span id="remarkMsg" style="color: red"></span>
								<!-- <input type="text" class="form-control" id="bankOfDeposit" name="bankOfDeposit" placeholder="最低售价" style="width: 150px; height: 20px;">
								<span id="bankOfDepositMsg" style="color: red"></span> -->
							</td>
						</tr>

						<tr>
							<td style="width: 86px; text-align: right">
								配送价
							</td>
							<td>
								<input type="text" class="form-control" id="delverPrice" name="delverPrice" value="30" placeholder="配送价" style="width: 150px; height: 20px;">
							</td>
							<td style="width: 86px; text-align: right">
								会员价1
							</td>
							<td>
								<input type="text" class="form-control" id="vipPrice" name="vipPrice" placeholder="会员价" style="width: 150px; height: 20px;">
								<span id="accountMsg" style="color: red"></span>
							</td>
						</tr>

						<tr>
							<td style="width: 86px; text-align: right">
								商品状态
							</td>
							<td>
								<select class="form-control" id="state" name="state" style="width: 150px; height: 20px;">
									<option selected="selected" value="1">正常</option>
									<option value="2">停售</option>
									<option value="3">停购</option>
									<option value="4">淘汰</option>
								</select>
							</td>
							<td style="width: 86px; text-align: right">
								库管上限
							</td>
							<td>
								<input type="text" class="form-control" id="maxStock" name="maxStock" placeholder="库管上限" style="width: 150px; height: 20px;">
							</td>
						</tr>
						<tr>
							<td style="width: 86px; text-align: right">
								单位
							</td>
							<td>
								<input type="text" class="form-control" id="unit" name="unit" placeholder="单位" style="width: 150px; height: 20px;">
							</td>
							<td style="width: 86px; text-align: right">
								库管下限
							</td>
							<td>
								<input type="text" class="form-control" id="minStock" name="minStock" placeholder="库管下限" style="width: 150px; height: 20px;">
							</td>
						</tr>
						</tbody>
					</table>
				</form>
				<div class="modal-footer" style="background-color: #ffffff">
					<button type="button" class="btn btn-default btn-xs" data-dismiss="modal" v-on:click="close">关闭</button>
					<button type="button" class="btn btn-primary btn-xs" id="saveProd">提交更改</button>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 数型内容 -->
<div id="authorizationInfoContentBrodBrand" class="hide">
	<div class="content_wrap">
		<div class="zTreeDemoBackground left" style="width: 190px;">
			<ul id="treeDemo" class="ztree"></ul>
		</div>
	</div>
</div>

<!-- page specific plugin scripts -->

<script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.mockjax.js"></script>
<script type="text/javascript" src="${contextPath}/static/statistics/js/jquery.autocomplete.js"></script>
<!-- jqGrid 公用类 -->
<script type="text/javascript">



    function style_edit_form(form) {
        //enable datepicker on "sdate" field and switches for "stock" field
        //form.find('input[name=sdate]').datepicker({format:'yyyy-mm-dd' , autoclose:true})

        //form.find('input[name=stock]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
        //don't wrap inside a label element, the checkbox value won't be submitted (POST'ed)
        //.addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');


        //update buttons classes
        var buttons = form.next().find('.EditButton .fm-button');
        buttons.addClass('btn btn-sm').find('[class*="-icon"]').hide();//ui-icon, s-icon
        buttons.eq(0).addClass('btn-primary').prepend('<i class="ace-icon fa fa-check"></i>');
        buttons.eq(1).prepend('<i class="ace-icon fa fa-times"></i>')

        buttons = form.next().find('.navButton a');
        buttons.find('.ui-icon').hide();
        buttons.eq(0).append('<i class="ace-icon fa fa-chevron-left"></i>');
        buttons.eq(1).append('<i class="ace-icon fa fa-chevron-right"></i>');
    }

    function style_delete_form(form) {
        var buttons = form.next().find('.EditButton .fm-button');
        buttons.addClass('btn btn-sm btn-white btn-round').find('[class*="-icon"]').hide();//ui-icon, s-icon
        buttons.eq(0).addClass('btn-danger').prepend('<i class="ace-icon fa fa-trash-o"></i>');
        buttons.eq(1).addClass('btn-default').prepend('<i class="ace-icon fa fa-times"></i>')
    }

    function style_search_filters(form) {
        form.find('.delete-rule').val('X');
        form.find('.add-rule').addClass('btn btn-xs btn-primary');
        form.find('.add-group').addClass('btn btn-xs btn-success');
        form.find('.delete-group').addClass('btn btn-xs btn-danger');
    }

    function style_search_form(form) {
        var dialog = form.closest('.ui-jqdialog');
        var buttons = dialog.find('.EditTable')
        buttons.find('.EditButton a[id*="_reset"]').addClass('btn btn-sm btn-info').find('.ui-icon').attr('class', 'ace-icon fa fa-retweet');
        buttons.find('.EditButton a[id*="_query"]').addClass('btn btn-sm btn-inverse').find('.ui-icon').attr('class', 'ace-icon fa fa-comment-o');
        buttons.find('.EditButton a[id*="_search"]').addClass('btn btn-sm btn-purple').find('.ui-icon').attr('class', 'ace-icon fa fa-search');
    }

    function beforeDeleteCallback(e) {
        var form = $(e[0]);
        if (form.data('styled')) return false;

        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
        style_delete_form(form);
        form.data('styled', true);
    }

    function beforeEditCallback(e) {
        var form = $(e[0]);
        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
        style_edit_form(form);
    }


    //it causes some flicker when reloading or navigating grid
    //it may be possible to have some custom formatter to do this as the grid is being created to prevent this
    //or go back to default browser checkbox styles for the grid
    function styleCheckbox(table) {
        /**
         $(table).find('input:checkbox').addClass('ace')
         .wrap('<label />')
         .after('<span class="lbl align-top" />')


         $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
         .find('input.cbox[type=checkbox]').addClass('ace')
         .wrap('<label />').after('<span class="lbl align-top" />');
         */
    }


    //unlike navButtons icons, action icons in rows seem to be hard-coded
    //you can change them like this in here if you want
    function updateActionIcons(table) {
        /**
         var replacement =
         {
             'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue',
             'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red',
             'ui-icon-disk' : 'ace-icon fa fa-check green',
             'ui-icon-cancel' : 'ace-icon fa fa-times red'
         };
         $(table).find('.ui-pg-div span.ui-icon').each(function(){
				var icon = $(this);
				var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
				if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
			})
         */
    }

    //replace icons with FontAwesome icons like above
    function updatePagerIcons(table) {
        var replacement =
            {
                'ui-icon-seek-first': 'ace-icon fa fa-angle-double-left bigger-140',
                'ui-icon-seek-prev': 'ace-icon fa fa-angle-left bigger-140',
                'ui-icon-seek-next': 'ace-icon fa fa-angle-right bigger-140',
                'ui-icon-seek-end': 'ace-icon fa fa-angle-double-right bigger-140'
            };
        $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function () {
            var icon = $(this);
            var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

            if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]);
        })
    }

    function enableTooltips(table) {
        $('.navtable .ui-pg-button').tooltip({container: 'body'});
        $(table).find('.ui-pg-div').tooltip({container: 'body'});
    }

    //var selr = jQuery(grid_product_selector).jqGrid('getGridParam','selrow');

    $(document).one('ajaxloadstart.page', function (e) {
        $.jgrid.gridDestroy(grid_product_selector);
        $('.ui-jqdialog').remove();
    });
</script>
<!-- 通用 -->
<script type="text/javascript">
    var grid_product_selector = "#grid-product-table";
    var pager_product_selector = "#grid-product-pager";

	var grid_brand_table = "#grid-brand-table";
	var grid_brand_pager = "#grid-brand-pager";

    var grid_prodType_selector = "#grid-prodType-table";
    var pager_prodType_selector = "#grid-prodType-pager";

	var laypage = layui.laypage,
		layer = layui.layer
	laydate = layui.laydate;

	var queryModel = {
		parentId: '0'
	}

	var app = new Vue({
		el: '#app',
		data: {
			objects: [],
			yanType1: [],
			yanType2: [],
			yanType3: [],
			yanType4: [],
			yanType5: [],
            typeNameArray: []
		},
		methods: {
			close: function () {
                layer.close(modalIndexProd);
			}
		}
	})

</script>
<!-- 业务 -->
<script type="text/javascript">

    var getObjects = function (queryModel) {
        layer.load(1)
		console.log(queryModel)
        queryModel.id = queryModel.productId;
        $.ajax({
            url: '${contextPath}/ktProd/saveProd',
            type: 'post',
            data: queryModel,
            success: function (data) {
                layer.closeAll('loading');
                if (data.success == false){
                    layer.msg("获取出错："+data.message,{icon:0})
                    return
                }

                var dataArray = data.data;
                layer.close(modalIndexProd);
                layer.msg("提示："+data.message,{icon:1})
                reload();
            },
            error: function (error) {
                layer.closeAll('loading')
                layer.msg("错误提示："+data.message,{icon:0})
            }
        })
    }

    var queryObjects = function () {
        var obj = $("#productForm").serializeJson();
        getObjects(obj)
    }


	$("#saveProd").click(function () {
		var productCode = $("#productCode").val();
		var selfCode = $("#selfCode").val(); 
		var productName = $("#productName").val();
		var brandName = $("#brandName").val();
		var typeName = $("#typeName").val();
		var spec = $("#spec").val();
		var stockSpec = $("#stockSpec").val();
		var productTypeId = $("#productTypeId").val();
		var freezeAccounts = $("#freezeAccounts").val();
		var cstPrice = $("#cstPrice").val();
		var rtlPrice = $("#rtlPrice").val();
		var dispatchPrice = $("#dispatchPrice").val();
		var bankOfDeposit = $("#bankOfDeposit").val();
		var delverPrice = $("#delverPrice").val(); 
		var vipPrice = $("#vipPrice").val();  
		var state = $("#state").val(); 
		var maxStock = $("#maxStock").val();
		var unit = $("#unit").val();
		var minStock = $("#minStock").val();
		
		var dispatchPrice = $("#dispatchPrice").val();
		var dispatchPcsPrice = $("#dispatchPcsPrice").val();
		if(productCode == ""){
			layer.msg("请输入条码");
			return false;
		}else if(productName == ""){
			layer.msg("请输入商品名称");
			return false;
		}
//		else if(brandName == ""){
//			layer.msg("请输入品牌");
//			return false;
//		}
		else if(cstPrice == ""){
			layer.msg("请输入进价");
			return false;
		}else if(rtlPrice == ""){
			layer.msg("请输入零售价");
			return false;
		}
        queryObjects();
    })

    /**
     * 搜索店铺
     */
    var searchProd = function() {
		//        var typeId = "";
//        var parentId = queryModel.parentId;
        var supplierName = $("#supplierName").val();
        var productCode = $("#productCode1").val();
        var state = $("#state1").val();
        var productName = $("#productName1").val();
        var typeId = queryModel.parentId == null ? "" : queryModel.parentId;
        //var parentDepartmentkey = $("#id_parentDepartmentkey_name").val();

        var filters = {
            "rules": [
                {"field": "productCode", "data": productCode},
                {"field": "productName", "data": productName},
                {"field": "supplierName", "data": supplierName},
                {"field": "typeId", "data": typeId},
                {"field": "state", "data": state}
            ]
        };
        //console.log(JSON.stringify(filters))
        jQuery(grid_product_selector).jqGrid('setGridParam', {
            postData: {
                "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
            }
        }).trigger("reloadGrid");
	}
</script>
<!-- 下啦联动 -->
<script type="text/javascript">
/**
 * 下啦联动数据绑定 开始代码
 * @type {{parentId: string}}
 */
$('#isExpInput').change(function () {
    app.yanType2 = []
    app.yanType3 = []
    app.yanType4 = []
    $("#commodityScreen").addClass("hide");
    queryModel.parentId = $("#isExpInput option:selected").val();
    //////console.log(32456789)
    querySubProdType2()
});

$('#isAuthInput').change(function () {
    app.yanType3 = []
    app.yanType4 = []
    $("#commodityScreen").addClass("hide");
    queryModel.parentId = $("#isAuthInput option:selected").val();
    querySubProdType3()
});

$('#isAuthInput1').change(function () {
    app.yanType4 = []
    $("#commodityScreen").addClass("hide");
    queryModel.parentId = $("#isAuthInput1 option:selected").val();
    querySubProdType4()
});

$('#isAuthInput2').change(function () {
    app.yanType5 = []
    $("#commodityScreen").addClass("hide");
    queryModel.parentId = "";
    queryModel.parentId = $("#isAuthInput2 option:selected").val();
    querySubProdType5()
});

var querySubProdType1 = function () {
    getSubProdType1(queryModel)
}
var querySubProdType2 = function () {
    getSubProdType2(queryModel)
}
var querySubProdType3 = function () {
    getSubProdType3(queryModel)
}
var querySubProdType4 = function () {
    getSubProdType4(queryModel)
}
var querySubProdType5 = function () {
    getSubProdType5(queryModel)
}


var getSubProdType1 = function (queryModel) {
    // ////console.log(queryModel)
//        layer.load(1)
    $.ajax({
        url: '${contextPath}/ktProd/getSubProdType',
        type: 'post',
        data: queryModel,
        success: function (data) {
//                layer.closeAll('loading');
            var dataArray = data;

            if (dataArray.length == 0){
                layer.msg("查询没有数据")
                return
            }
//                 ////console.log("dataArray: "+dataArray)
            app.yanType1 = dataArray;

        },
        error: function (error) {
//                layer.closeAll('loading')
        }
    })
}

var getSubProdType2 = function (queryModel) {
    ////console.log(queryModel)
    $.ajax({
        url: '${contextPath}/ktProd/getSubProdType',
        type: 'post',
        data: queryModel,
        success: function (data) {
            if (data.success == false){
                layer.msg("获取出错："+data.message)
                return
            }
            var dataArray = data;

            if (dataArray.length == 0){
                layer.msg("查询没有数据")
                return
            }
            ////console.log("dataArray: "+dataArray)
            app.yanType2 = dataArray;

        },
        error: function (error) {
        }
    })
}

var getSubProdType3 = function (queryModel) {
    ////console.log(queryModel)
//        layer.load(1)
    $.ajax({
        url: '${contextPath}/ktProd/getSubProdType',
        type: 'post',
        data: queryModel,
        success: function (data) {
//                layer.closeAll('loading');
            if (data.success == false){
                layer.msg("获取出错："+data.message)
                return
            }
            var dataArray = data;

            if (dataArray.length == 0){
                layer.msg("查询没有数据")
                return
            }
//                ////console.log("dataArray: "+dataArray)
            app.yanType3 = dataArray;

        },
        error: function (error) {
//                layer.closeAll('loading')
        }
    })
}

var getSubProdType4 = function (queryModel) {
    // ////console.log(queryModel)
//        layer.load(1)
    $.ajax({
        url: '${contextPath}/ktProd/getSubProdType',
        type: 'post',
        data: queryModel,
        success: function (data) {
//                layer.closeAll('loading');
            if (data.success == false){
                layer.msg("获取出错："+data.message)
                return
            }
            var dataArray = data;

            if (dataArray.length == 0){
                layer.msg("查询没有数据")
                return
            }
//                ////console.log("dataArray: "+dataArray)
            app.yanType4 = dataArray;

        },
        error: function (error) {
//                layer.closeAll('loading')
        }
    })
}

var getSubProdType5 = function (queryModel) {
    // ////console.log(queryModel)
//        layer.load(1)
    $.ajax({
        url: '${contextPath}/ktProd/getProdProperty',
        type: 'post',
        data: queryModel,
        success: function (data) {
//                layer.closeAll('loading');
            if (data.success == false){
                layer.msg("获取出错："+data.message)
                return
            }
            var dataArray = data;

            if (dataArray.length == 0){
                layer.msg("查询没有数据")
                return
            }
            $("#commodityScreen").removeClass("hide");
            ////console.log("dataArray: "+dataArray)
            app.yanType5 = dataArray;

        },
        error: function (error) {
//                layer.closeAll('loading')
        }
    })
}

querySubProdType1(queryModel);

/**
 * 下啦联动数据绑定 结束代码
 */

</script>
<!-- jqGrid 数据加载 -->
<script type="text/javascript">

    var filters = {
        "rules": [
            {"field": "remark", "data": '科泰'},
            // {"field": "typeId", "data": '05'},
            // {"field": "unit", "data": unit},
            // {"field": "state", "data": '1'},
        ]
    };

    var grid_data = {'filters': JSON.stringify(filters)};
    console.log(grid_data)

	var scripts = [null, "${contextPath}/static/ace/components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js", "${contextPath}/static/ace/components/jqGrid/js/jquery.jqGrid.js", "${contextPath}/static/ace/components/jqGrid/js/i18n/grid.locale-cn.js", "${contextPath}/static/layer/layer.js","${contextPath}/static/ztree/js/jquery.ztree.core-3.5.js", "${contextPath}/static/ztree/js/jquery.ztree.excheck-3.5.js", null]
	$('.page-content-area').ace_ajax('loadScripts', scripts, function () {
		jQuery(function ($) {
			var parent_column = $(grid_product_selector).closest('[class*="col-"]');
			//resize to fit page size
			$(window).on('resize.jqGrid', function () {
				$(grid_product_selector).jqGrid('setGridWidth', parent_column.width());
			})

			//resize on sidebar collapse/expand
			$(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
				if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
					//setTimeout is for webkit only to give time for DOM changes and then redraw!!!
					setTimeout(function () {
						$(grid_product_selector).jqGrid('setGridWidth', parent_column.width());
					}, 20);
				}
			})

			jQuery(grid_product_selector).jqGrid({
				//direction: "rtl",

				//subgrid options
				subGrid: false,
				url: "${contextPath}/ktProd/getProdInfo",
	           postData: grid_data,
				datatype: "json",
				mtype: 'POST',
				height: 312,
				colNames: ['编号', '商品名称', '供应商Id', '供应商名称','类型Id', '类型', '分类Id', '分类', '条码','状态编号','状态','单位','规格', '操作时间','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38'],
				colModel: [
					{name: 'productId', index: 'productId', width: 60, editable: true},   //商品Id
					{
						name: 'productName',
						index: 'productName',
						width: 110,
						editable: true,
						sortable: false,
						editrules: {required: true}
					},  //商品名称
					{name: 'supplierId', index: 'supplierId', width: 60, editable: true, hidden: true,},
					{
						name: 'supplierName', index: 'supplierName', width: 60, editable: true,
						edittype: 'select',
						hidden:true,
						//editoptions: {value:gettypes('${contextPath}/ktPurchase/getSupplierListByPage', 'recordList', 'supplierName')}
					},
					{
						name: 'productTypeId',
						index: 'productTypeId',
						width: 90,
						editable: true,
						sortable: false,
                        hidden: true,
						editrules: {required: true},
						<%--edittype: 'select',--%>
							<%--editoptions: {value:gettypes('${contextPath}/ktPurchase/getSupplierListByPage', 'recordList', 'supplierName')}--%>
                    }, //商品类型
                    {
                        name: 'productTypeName',
                        index: 'productTypeName',
                        width: 90,
                        editable: true,
                        sortable: false,
                        hidden: true,
                        editrules: {required: true},
                        <%--edittype: 'select',--%>
                        <%--editoptions: {value:gettypes('${contextPath}/ktPurchase/getSupplierListByPage', 'recordList', 'supplierName')}--%>
                    }, //商品类型
                    {
                        name: 'prodTypeId',
                        index: 'prodTypeId',
                        width: 90,
                        editable: true,
                        sortable: false,
						hidden: true,
                        editrules: {required: true},
                        <%--edittype: 'select',--%>
                        <%--editoptions: {value:gettypes('${contextPath}/ktPurchase/getSupplierListByPage', 'recordList', 'supplierName')}--%>
                    },
                    {
                        name: 'typeName',
                        index: 'typeName',
                        width: 90,
                        editable: true,
                        sortable: false,
                        editrules: {required: true},
                        <%--edittype: 'select',--%>
                        <%--editoptions: {value:gettypes('${contextPath}/ktPurchase/getSupplierListByPage', 'recordList', 'supplierName')}--%>
                    }, //商品分类
                    {
                        name: 'productCode',
                        index: 'productCode',
                        width: 90,
                        editable: true,
                        sortable: false,
                        editrules: {required: true}
                    },
                    {
                        name: 'state',
                        index: 'state',
                        width: 90,
                        editable: true,
                        sortable: false,
						hidden: true,
                        edittype: 'select',
                    },  //商品状态
                    {
                        name: 'stateName',
                        index: 'stateName',
                        width: 90,
                        editable: true,
                        sortable: false,
                        edittype: 'select',
                        formatter: function (v, x, r) {
                        	//console.log("返回数据==》",r);
                            var state = r['state'];
                            if (state == '1'){
                                return '正常'
                            }
                            if (state == '2'){
                                return '停售'
                            }
                            if (state == '3'){
                                return '停购'
                            }
                            if (state == '4'){
                                return '淘汰'
                            }
                        }
//                        editoptions: {value: "0:有效;1:无效"}
                    },  //商品名称
                    {
                        name: 'unit',
                        index: 'unit',
                        width: 90,
                        editable: true,
                        sortable: false
                    }, //单位
					{
                        name: 'spec',
                        index: 'spec',
                        width: 90,
                        editable: true,
                        sortable: false
                    }, //规格
                    {name: 'stateDate', index: 'stateDate', width: 150, editable: false},
                    
                    
                    {name: 'validateDay', index: 'validateDay', hidden: true},
                    {name: 'remark', index: 'remark', hidden: true},
                    {name: 'imageUrl', index: 'imageUrl', hidden: true},
                    {name: 'mfrName', index: 'mfrName', hidden: true},
                    {name: 'brandId', index: 'brandId', hidden: true},
                    {name: 'productType', index: 'productType', hidden: true},
                    {name: 'stockSpec', index: 'stockSpec', hidden: true},
                    {name: 'productTypeId1', index: 'productTypeId1', hidden: true},
                    {name: 'modifyTime', index: 'modifyTime', hidden: true},
                    {name: 'packQrCode', index: 'packQrCode', hidden: true},
                    {name: 'packAmt', index: 'packAmt', hidden: true},
                    {name: 'supplierId', index: 'supplierId', hidden: true},
                    {name: 'categoryId', index: 'categoryId', hidden: true},
                    {name: 'shopModifyFlag', index: 'shopModifyFlag', hidden: true},
                    {name: 'createUser', index: 'createUser', hidden: true},
                    {name: 'selfCode', index: 'selfCode', hidden: true},  //自编码
                    {name: 'dispatchPrice', index: 'dispatchPrice', hidden: true},  //批发价
                    {name: 'dispatchPcsPrice', index: 'dispatchPcsPrice', hidden: true},//批条价
                    {name: 'delFlag', index: 'delFlag', hidden: true},
                    {name: 'createTime', index: 'createTime', hidden: true},
                    {name: 'cstPrice', index: 'cstPrice', hidden: true},  //进价
                    {name: 'bonusPointsFlag', index: 'bonusPointsFlag', hidden: true},
                    {name: 'detailImageUrl', index: 'detailImageUrl', hidden: true},
                    {name: 'isTop15', index: 'isTop15', hidden: true},
                    {name: 'reserve02', index: 'reserve02', hidden: true},
                    {name: 'reserve01', index: 'reserve01', hidden: true},
                    {name: 'qrCode', index: 'qrCode', hidden: true},
                    {name: 'rtlPrice', index: 'rtlPrice', hidden: true},  //零售价
					{name: 'shortCode', index: 'shortCode', hidden: true},
					{name: 'address', index: 'address', hidden: true},
					{name: 'modifyUser', index: 'modifyUser', hidden: true},
                    {name: 'brandName', index: 'brandName', hidden: true},  //品牌
					{name: 'prodBrandId', index: 'prodBrandId', hidden: true},  //品牌Id
					{name: 'helpCode', index: 'helpCode', hidden: true},
					{name: 'vipPrice', index: 'vipPrice', hidden: true},   //会员价
					{name: 'deliverPrice', index: 'deliverPrice', hidden: true},
					{name: 'shortName', index: 'shortName', hidden: true},
					{name: 'minPrice', index: 'minPrice', hidden: true},
				],
                rownumbers: true, //自动行数
                viewrecords: true,
                rowNum: 10,
                rowList: [10, 20, 30],
                pager: pager_product_selector,
				shrinkToFit: true,
                altRows: true,
                //toppager: true,

                multiselect: false,
                //multikey: "ctrlKey",
                multiboxonly: true,

                loadComplete: function () {
                    var table = this;
                    setTimeout(function () {
                        styleCheckbox(table);

                        updateActionIcons(table);
                        updatePagerIcons(table);
                        enableTooltips(table);
                    }, 0);
                },

                //editurl: "${contextPath}/ktProd/saveProd",//nothing is saved
                caption: "商品信息管理",
                jsonReader: {
                    root: "recordList",
                    page: "currentPage",
                    total: "pageCount",
                    records: "recordCount"
                }

                //,autowidth: true,
                /**
                 ,
                 grouping:true,
                 groupingView : {
				 groupField : ['name'],
				 groupDataSorted : true,
				 plusicon : 'fa fa-chevron-down bigger-110',
				 minusicon : 'fa fa-chevron-up bigger-110'
			},
                 caption: "Grouping"
                 */

            });
            $(window).triggerHandler('resize.jqGrid');//trigger window resize to make the grid get the correct size

			$("#jqgh_grid-product-table_rn").html('行号');
            $("#jqgh_grid-product-table_rn").css("font-size", "13px");
			$("#jqgh_grid-product-table_rn").css("text-align", "center");
			$("#grid-product-table_rn").css({"width": "36px"});

			//enable search/filter toolbar
			//jQuery(grid_product_selector).jqGrid('filterToolbar',{defaultSearch:true,stringResult:true})
			//jQuery(grid_product_selector).filterToolbar({});


			//switch element when editing inline
			function aceSwitch(cellvalue, options, cell) {
				setTimeout(function () {
					$(cell).find('input[type=checkbox]')
						.addClass('ace ace-switch ace-switch-5')
						.after('<span class="lbl"></span>');
				}, 0);
			}

			//enable datepicker
			function pickDate(cellvalue, options, cell) {
				setTimeout(function () {
					$(cell).find('input[type=text]')
						.datepicker({format: 'yyyy-mm-dd', autoclose: true});
				}, 0);
			}

			//navButtons
			jQuery(grid_product_selector).jqGrid('navGrid', pager_product_selector,
				{ 	//navbar options
					edit: false,
					editicon: 'ace-icon fa fa-pencil blue',
					add: false,
					addicon: 'ace-icon fa fa-plus-circle purple',
					del: false,
					delicon: 'ace-icon fa fa-trash-o red',
					search: false,
					searchicon: 'ace-icon fa fa-search orange',
					refresh: true,
					refreshicon: 'ace-icon fa fa-refresh green',
					view: false,
					viewicon: 'ace-icon fa fa-search-plus grey',
				},
				{
					//edit record form
					//closeAfterEdit: true,
					//width: 700,
					recreateForm: true,
					beforeShowForm: function (e) {
						var form = $(e[0]);
						form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
						style_edit_form(form);
					}
				},
				{
					//new record form
					//width: 700,
					closeAfterAdd: true,
					recreateForm: true,
					viewPagerButtons: false,
					beforeShowForm: function (e) {
						var form = $(e[0]);
						form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar')
							.wrapInner('<div class="widget-header" />')
						style_edit_form(form);
					}
				},
				{
					//delete record form
					recreateForm: true,
					beforeShowForm: function (e) {
						var form = $(e[0]);
						if (form.data('styled')) return false;

						form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
						style_delete_form(form);

						form.data('styled', true);
					},
					onClick: function (e) {
						//alert(1);
					}
				},
				{
					//search form
					recreateForm: true,
					afterShowSearch: function (e) {
						var form = $(e[0]);
						form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
						style_search_form(form);
					},
					afterRedraw: function () {
						style_search_filters($(this));
					}
					,
					multipleSearch: true,
					/**
					 multipleGroup:true,
					 showQuery: true
					 */
				},
				{
					//view record form
					recreateForm: true,
					beforeShowForm: function (e) {
						var form = $(e[0]);
						form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
					}
				}
			)
		})
    });
</script>
<script src="${contextPath}/static/countjs/select.js"></script>

<script type="text/javascript">
    var reload = function () {
//        $(grid_selector).jqGrid('clearGridData');  //清空表格
        $(grid_product_selector).jqGrid('setGridParam',{
            url:"${contextPath}/ktProd/getProdInfo",
            datatype:'json',
//                    postData:param,
            page:1
        }).trigger("reloadGrid"); //重新载入
    }
</script>

<!-- 模态框 -->
<script>
    jQuery(function($){
        //解决模态框背景色越来越深的问题
        $(document).on('show.bs.modal', '.modal', function(event) {
            $(this).appendTo($('body'));
        }).on('shown.bs.modal', '.modal.in', function(event) {
            setModalsAndBackdropsOrder();
        }).on('hidden.bs.modal', '.modal', function(event) {
            setModalsAndBackdropsOrder();
        });

        function setModalsAndBackdropsOrder() {
            var modalZIndex = 1040;
            $('.modal.in').each(function(index) {
                var $modal = $(this);
                modalZIndex++;
                $modal.css('zIndex', modalZIndex);
                $modal.next('.modal-backdrop.in').addClass('hidden').css('zIndex', modalZIndex - 1);
            });
            $('.modal.in:visible:last').focus().next('.modal-backdrop.in').removeClass('hidden');
        }

        //覆盖Modal.prototype的hideModal方法
        $.fn.modal.Constructor.prototype.hideModal = function () {
            var that = this
            this.$element.hide()
            this.backdrop(function () {
                //判断当前页面所有的模态框都已经隐藏了之后body移除.modal-open，即body出现滚动条。
                $('.modal.fade.in').length === 0 && that.$body.removeClass('modal-open')
                that.resetAdjustments()
                that.resetScrollbar()
                that.$element.trigger('hidden.bs.modal')
            })
        }
    });
</script>
<!-- 调用方法 -->
<script type="text/javascript">
    /**
     * 搜索品牌
     */
    function searchProduct() {
        var brandName = $("#searcBrandName").val();
        //var parentDepartmentkey = $("#id_parentDepartmentkey_name").val();
        var filters = {
            "rules": [
                {
                    "field": "brandName",
                    "data": brandName
                },
                {
                    "field": "state",
                    "data": '1'
                }
            ]
        };

        ////console.log(filters)

        jQuery(grid_brand_table).jqGrid('setGridParam', {
            postData: {
                "filters": JSON.stringify(filters) //"{'rules' : [{'field' : 'shopName','data' : "+shopName+"},{'field' : 'state','data' : "+state+"}]}"
            }
        }).trigger("reloadGrid");
    }
</script>

<!-- 数型插件 -->
<script type="text/javascript">

    $("#editProd").click(function () {
        var id = $(grid_product_selector).jqGrid('getGridParam', 'selrow');
        if (!id) {
            layer.msg("提示：请选择一条信息");
            return;
        }
        var rowData = $(grid_product_selector).jqGrid('getRowData', id);
        console.log(rowData)
        $("#productForm").setForm(rowData)
        layerOpen('修改')
    });

    $("#addCargo").click(function () {
    	$("#productCode").removeAttr("readonly");
        $("#productForm")[0].reset();
        layerOpen('新增')
    });


    var layerOpen = function (title) {
//        $("#productForm")[0].reset();
//        $.fn.zTree.init($("#treeDemoShop"));
        $("#authorizationInfoContentProd").removeClass("hide")
        modalIndexProd = layer.open({
            type: 1,
            title: title,
            closeBtn: 1,
            shadeClose: true,
            maxmin: true,
            area: ['650px'],
            skin: 'yourclass',
            content: $("#authorizationInfoContentProd"),
            end: function () {
                $("#authorizationInfoContentProd").addClass("hide")
            }
        });
    }

    //-- 弹出品牌 --
    $("#brandName").click(function(){
//        layer.load(1);
        var setting = {
            view: {
                dblClickExpand: false,
                showLine: true,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "parentId",
                    rootPId: '0',
                },
				key: {
                    name: 'brandName'
				}
            },
            <%--async: {--%>
                <%--enable: false, // 设置 zTree是否开启异步加载模式  加载全部信息--%>
                <%--url: "${contextPath}/ktProd/getProdType", // Ajax 获取数据的 URL 地址--%>
                <%--autoParam: ["0"],    // 异步加载时自动提交父节点属性的参数,假设父节点 node = {id:1, name:"test"}，异步加载时，提交参数 zId=1--%>
<%--//                dataFilter: queryModels,--%>
            <%--},--%>
            callback: { //回调函数
                /**
                 * event:鼠标事件
                 * treeId：树的容器id
                 * treeNode：当前点击的节点
                 */
                	//双击
				  onDblClick: function (treeId, treeNode) {
                    layer.closeAll('loading');
					  var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
					  var node = treeObj.getSelectedNodes();//点击节点后 获取节点数据
                    $("#brandName").val(node[0].brandName)
                    $("#prodBrandId").val(node[0].id)
                    layer.close(modalIndex)
				  }
            }
        }
		var dataArray = app.brandArray;
        var zNodes =[];
		$.fn.zTree.init($("#treeDemo"), setting, dataArray);
		$("#authorizationInfoContentBrodBrand").removeClass("hide")
		modalIndex = layer.open({
			type: 1,
			title: '列表',
			closeBtn: 1,
			shadeClose: true,
			maxmin: true,
			area: ['200px', '550px'],
			skin: 'yourclass',
			content: $("#authorizationInfoContentBrodBrand"),
			end: function () {
				$("#authorizationInfoContentBrodBrand").addClass("hide")
			}
		});

    })
    /* 弹出商品分类  */
    $("#typeName").click(function(){
//        layer.load(1)
        var setting = {
                view: {
                    dblClickExpand: false,
                    showLine: true,
                    selectedMulti: false
                },
                data: {
                    simpleData: {
                        enable: true,
                        idKey: "typeId",
                        pIdKey: "parentId",
                        rootPId: '',
                    },
    				key: {
                        name: 'typeName'
    				}
                },
                callback: { //回调函数
                    /**
                     * event:鼠标事件
                     * treeId：树的容器id
                     * treeNode：当前点击的节点
                     */
                    	//双击
    				  onDblClick: function (treeId, treeNode) {
                        layer.closeAll('loading');
    					  var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
    					  var node = treeObj.getSelectedNodes();//点击节点后 获取节点数据
                        $("#productTypeId").val(node[0].id.substring(0,2))
                        $("#typeName").val(node[0].typeName)
                        $("#prodTypeId").val(node[0].id)
                        layer.close(modalIndex)
    				  }
                }
            }

        var zNodes =[];
		var dataArray = app.typeNameArray;
		$.fn.zTree.init($("#treeDemo"), setting, dataArray);
		$("#authorizationInfoContentBrodBrand").removeClass("hide")
		modalIndex = layer.open({
			type: 1,
			title: '列表',
			closeBtn: 1,
			shadeClose: true,
			maxmin: true,
			area: ['200px', '550px'],
			skin: 'yourclass',
			content: $("#authorizationInfoContentBrodBrand"),
			end: function () {
				$("#authorizationInfoContentBrodBrand").addClass("hide")
			}
		});
    })

	//获取分类
	var getType = function () {
        var filters = {
            "rules": [
                {
                    "field": "state",
                    "data": '1'
                }
            ]
        };
        var queryModels = {
            page: '1',
            rows: '10000',
            filters: JSON.stringify(filters),
        };
        $.ajax({
            url : "${contextPath}/ktProd/getProdType",
            type : "get",
            data : queryModels,
            dataType : "json",
            async : false,
            success : function(data) {
                layer.closeAll('loading');
                var dataArray = data.recordList;
                app.typeNameArray = dataArray;
                //console.log("dataArray",dataArray);
            },
            error : function () {
                layer.closeAll('loading');
                layer.msg("网络异常")
            }
        });
    }

    var getBrand = function () {
        var filters = {
            "rules": [
                {
                    "field": "state",
                    "data": '1'
                }
            ]
        };
        var queryModels = {
            page: '1',
            rows: '10000',
            filters: JSON.stringify(filters),
        };

        $.ajax({
            url : "${contextPath}/ktProd/getProdBrandListByPage",
            type : "get",
            data : queryModels,
            dataType : "json",
            async : false,
            success : function(data) {
                layer.closeAll('loading');
                var dataArray = data.recordList;
                app.brandArray = dataArray;
            },
            error : function () {
                layer.closeAll('loading');
                layer.msg("网络异常")
            }
        });
    }

    $(function () {
        getType();
        getBrand();
    })
</script>